﻿using UnityEngine;
using System.Collections;
using System.Text.RegularExpressions;


public class MainMenuAle : MonoBehaviour 
{
	private string players = "1"; 
	
	
	void OnGUI()
	{
		if(players == "")
			players= "1";
		
		int i = int.Parse(players);
		
		i = Mathf.Clamp(i, 1, 8);

		players = i.ToString();
		
		players = GUI.TextField(new Rect(Screen.width * 0.5f, Screen.height * 0.45f, 100, 30), players);
		
		Regex rgx = new Regex("[^0-9]");
		players = rgx.Replace(players, "1");
		
		
		if (GUI.Button(new Rect(Screen.width * 0.5f, Screen.height * 0.5f, 100, 30), "Start Game"))
		{
			PlayerPrefs.SetInt("Number of players", i);
            Application.LoadLevel("CFS");
		}
	}
}
